import axios from "axios";
import { get, post } from "@/request";

/* 注册 */
export const postRegister = ({ account, password }) =>
  post("/login/regisHandle", { account, password });

/* 账号密码登录 */
export const getLogin = ({ account, password }) =>
  get("/login/account", { account, password });

/* 退出登录 */
export const logout = () => get("/login/logout");

export const getUserDetail = (token) =>
  axios.get("/user/mydetail", {
    headers: {
      Authorization: token,
    },
  });

/* 获取用户歌单 */
export const getUserPlayList = () =>
  axios.get("/playList/myplayList", {
    headers: {
      Authorization: localStorage.getItem("token"),
    },
  });

/* 更新用户信息 */
export const updateUserInfo = ({
  token,
  gender,
  signature,
  nickname,
  birthday,
}) =>
  axios.get(
    `/user/update?gender=${gender}&signature=${signature}&nickname=${nickname}&birthday=${birthday}`,
    {
      headers: {
        Authorization: token, 
      },
    }
  );

/* 更新用户头像 */
export const uploadAvatar = ({ token, file }) =>
  axios.post(`/user/photoupload`, file, {
    "Content-Type": "multipart/form-data",
    headers: {
      Authorization: token,
    },
  });
